package com.san.hkhospital.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.san.hkhospital.vo.BedTableVo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.san.hkhospital.entity.BedExample;
import com.san.hkhospital.mapper.BedMapper;
import com.san.hkhospital.entity.Bed;
import com.san.hkhospital.service.BedService;
import org.springframework.transaction.annotation.Transactional;

/**
 * ClassName:BedServiceImpl
 * PackageName:com.san.hkhospital.service.impl
 * Description:
 *
 * @Author:yy
 * @CreatedAt:2024/11/13 14:38
 * 
 */
 
 
@Service
@Transactional
public class BedServiceImpl implements BedService{

    @Resource
    private BedMapper bedMapper;

    @Override
    public long countByExample(BedExample example) {
        return bedMapper.countByExample(example);
    }

    @Override
    public int deleteByExample(BedExample example) {
        return bedMapper.deleteByExample(example);
    }

    @Override
    public int deleteByPrimaryKey(Integer bedId) {
        return bedMapper.deleteByPrimaryKey(bedId);
    }

    @Override
    public int insert(Bed record) {
        return bedMapper.insert(record);
    }

    @Override
    public int insertSelective(Bed record) {
        return bedMapper.insertSelective(record);
    }

    @Override
    public List<Bed> selectByExample(BedExample example) {
        return bedMapper.selectByExample(example);
    }

    @Override
    public Bed selectByPrimaryKey(Integer bedId) {
        return bedMapper.selectByPrimaryKey(bedId);
    }

    @Override
    public int updateByExampleSelective(Bed record,BedExample example) {
        return bedMapper.updateByExampleSelective(record,example);
    }

    @Override
    public int updateByExample(Bed record,BedExample example) {
        return bedMapper.updateByExample(record,example);
    }

    @Override
    public int updateByPrimaryKeySelective(Bed record) {
        return bedMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Bed record) {
        return bedMapper.updateByPrimaryKey(record);
    }


    @Override
    public List<BedTableVo> selectBed() {

        return bedMapper.selectAll();
    }

    @Override
    public boolean addBed(Bed bed) {

        return bedMapper.insertSelective(bed)>0?true:false;
    }


    @Override
    public boolean updateBed(Bed bed) {
        int i = bedMapper.updateByPrimaryKeySelective(bed);
        return i>0?true:false;
    }

    @Override
    public Bed findOneBed(Integer bedId) {
        Bed bed = bedMapper.selectByPrimaryKey(bedId);
        return bed;
    }

    @Override
    public PageInfo selectAll(Integer sectionId, Integer stateId,Integer pageNum,Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<BedTableVo> bed = bedMapper.selectAll(sectionId,stateId);
        PageInfo pi = new PageInfo<>(bed);
        return pi;
    }

    @Override
    public List<BedTableVo> selectAll2(Integer sectionId, Integer stateId) {
        List<BedTableVo> bed = bedMapper.selectAll(sectionId,stateId);
        return bed;
    }


}
